<?php

namespace app\admin\controller;

use app\common\business\AdminRole;
use app\common\lib\Param;
use app\common\lib\Show;
use think\response\Json;

class Statistics extends AdminBase
{
    /**
     * 顶部数量统计
     * @return Json
     */
    public function topNum(): Json
    {
        try {
            $result=(new \app\common\business\Statistics())->getTopNum();
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        return Show::success($result);
    }

    /**
     * 零活饼图
     * @return Json
     */
    public function workPie(){
        try {
            $result=(new \app\common\business\Statistics())->getWorkPie($this->departmentId);
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        return Show::success($result);
    }

    /**
     * 零活柱状图
     * @return Json
     */
    public function workLine(){
        try {
            $result=(new \app\common\business\Statistics())->getWorkLine($this->departmentId);
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        return Show::success($result);
    }

    /**
     * 用户饼图
     * @return Json
     */
    public function userPie(){
        try {
            $result=(new \app\common\business\Statistics())->getUserPie();
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        return Show::success($result);
    }

    /**
     * 排名表格
     * @return Json
     */
    public function table(){
        try {
            $result=(new \app\common\business\Statistics())->getTable();
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        return Show::success($result);
    }

    /**
     * 用户概览
     * @return Json
     */
    public function wxUserTable(){
        try {
            $result=(new \app\common\business\Statistics())->getWxUserTable();
        }catch (\Exception $e){
            return Show::error([], $e->getMessage(), $e->getCode());
        }
        return Show::success($result);
    }
}
